<template>
  <div class="box-boss">
    <el-card class="top">
      <div><el-button round @click="$router.back()">返回按钮</el-button></div>
      <div style="margin:30px 0">
        <span>用户ID:{{this.data3.id}}</span>
        <span style="margin:0 100px">用户昵称:{{this.data3.name}}</span>
        <span>联系电话:{{this.data3.phone}}</span>
      </div>
    </el-card>

    <el-card class="center">
      <h4>用户消费情况</h4>
      日期:
      <el-date-picker
       disabled
        type="date"
        placeholder="选择日期"
        style="width: 200px;"
        v-model="data1"
      ></el-date-picker>
      至
      <el-date-picker
       disabled
        type="date"
        placeholder="选择日期"
        style="width: 200px;"
        v-model="data2"
      ></el-date-picker>
      <div id="main" style="width: 100%;height:400px;"></div>
      <div class="box-ss">
        <p>订单总量:15281</p>
        <p>订单总额:{{this.data3.num}}元</p>
      </div>
    </el-card>
    <el-card class="bottom">
      <!-- 数据表单 -->
      <div class="form">
        <el-table :data="list" style="width: 100%">
          <el-table-column prop="store_id" label="商户编号" width="240">
          </el-table-column>
          <el-table-column prop="store_name" label="商户名" width="240">
          </el-table-column>
          <el-table-column prop="store_trade" label="行业" width="240">
          </el-table-column>
          <el-table-column prop="order_count" label="订单商品数量" width="240">
          </el-table-column>
          <el-table-column prop="saleroom" label="订单金额" width="240">
          </el-table-column>
          <el-table-column prop="data" label="消费日期">
          </el-table-column>
        </el-table>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  data () {
    return {
      drawChart () {
        // 基于准备好的dom，初始化echarts实例
        const myChart = this.$echarts.init(document.getElementById('main'))
        // 指定图表的配置项和数据
        const option = {
          tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
          },
          series: [
            {
              name: '访问来源',
              type: 'pie',
              radius: '55%',
              center: ['50%', '60%'],
              data: [
                { value: this.data3.num * 0.2, name: `生鲜:${this.data3.num * 0.19}元` },
                { value: this.data3.num * 0.2, name: `生鲜:${this.data3.num * 0.21}元` },
                { value: this.data3.num * 0.6, name: `生鲜:${this.data3.num * 0.6}元` }
              ],
              emphasis: {
                itemStyle: {
                  shadowBlur: 10,
                  shadowOffsetX: 0,
                  shadowColor: 'rgba(0, 0, 0, 0.5)'
                }
              }
            }
          ]
        }

        // 使用刚指定的配置项和数据显示图表。
        myChart.setOption(option)
      },
      list: [],
      data1: '2020-02-01',
      data2: new Date(),
      data3: {}
    }
  },
  created () {
    this.getlist()
    this.getli()
  },
  mounted () {
    this.drawChart()
  },
  methods: {
    async getlist () {
      const { data } = await this.$http.get('/personage')
      this.list = data.list
      data.list.forEach((item, index) => {
        item.newsaleroom = item.saleroom + '元'
      })
    },
    getli () {
      this.data3 = this.$route.params
    }
  }
}
</script>

<style scoped lang="less">
.box-boss{
  padding: 20px;
}
.top{
  margin-bottom: 15px;
}
.center {
  position: relative;
  margin-bottom: 15px;
  .box-ss {
    position: absolute;
    top: 60%;
    right: 15%;
  }
}

.bottom{
  position: relative;
}
</style>
